package com.devin.config;


import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer;

/**
 * @author: simpl
 * @date: 2020/3/30
 * @time: 14:51
 * @description: 
 */



@CrossOrigin
@Configuration
@EnableWebSocketMessageBroker
public class SpringSocketConfig implements WebSocketMessageBrokerConfigurer {

    @Override
    public void registerStompEndpoints(StompEndpointRegistry registry)
    {
        registry.addEndpoint("/ws").setAllowedOrigins("*").withSockJS();
       /* registry.setOrder();*/
    }




    @Override
    public void configureMessageBroker(MessageBrokerRegistry registry) {
        //   主题使用
        registry.enableSimpleBroker("/topic");
        //  发送消息使用
        registry.setApplicationDestinationPrefixes("/app");
    }
}
